<template>
  <view>
    <!-- <Card></Card> -->
    <!-- 饮食剂量 -->
    <view class="card">
      <view class="timer">2023-07-30-2023-08-06</view>
      <view class="timer_num">覆盖时间： 0% 检测次数： 0次</view>
      <view class="content">
        <view class="left">
          <text class="title">平均血糖</text>
          <text class="count">17.8</text>
        </view>
        <view class="left">
          <text class="title">糖化血红蛋白</text>
          <text class="count">17.8</text>
        </view>
      </view>
    </view>
    <!-- 时间点平均血糖 -->
    <view class="card">
      <view class="chatTitle">时间点平均血糖</view>
      <view class="charts-box">
        <qiun-data-charts type="line" :opts="opts" :chartData="chartData" canvas2d="true" />
      </view>
    </view>
    <!-- 糖化血红蛋白数值 -->
    <view class="card">
      <view class="chatTitle">糖化血红蛋白数值</view>
      <view class="charts-box">
        <qiun-data-charts type="line" :opts="opts1" :chartData="chartData1" canvas2d="true" />
      </view>
    </view>
    <view class="more" @click="recordGIS">
      <image src="https://s1.ax1x.com/2023/09/09/pPcuUL8.png" mode=""></image>
    </view>
  </view>
</template>

<script>
  // import Card from '@/components/Card/Card.vue'
  export default {
    data() {
      return {
        chartData: {}, // 时间点平均血糖数据
        // 间点平均血糖数据配置
        opts: {
          color: ["#429BCF"],
          padding: [15, 20, 10, 15],
          enableScroll: false,
          legend: {
            show:false,
          },
          xAxis: {
            disableGrid: false, // 设置绘制纵向网格
            // fontSize:10, // 刻度字体
            // rotateLabel:true, // 刻度字体倾斜
            labelCount:6, // 显示刻度数量
            boundaryGap:"justify", // 点对齐方式
            gridColor:'#eee', // 网格线颜色
            axisLine:false, // 不显示坐标轴线
            marginTop:10
          },
          yAxis: {
            disableGrid:true, // 设置不绘制横向网格
            data:[{
              min:0,
              textAlign:'center',
              tofix:0
            }]
          },
          extra: {
            line: {
              type: "straight",
              width: 2,
              activeType:'hollow'
            }
          }
        },
        // 糖化血红蛋白数值
        chartData1:{},
        opts1:{
          color: ["#429BCF"],
          padding: [15, 20, 10, 15],
          enableScroll: false,
          legend: {
            show:false,
          },
          xAxis: {
            marginTop:10,
            axisLine:false
          },
          yAxis: {
            gridType:"solid",
            gridColor:"#eee",
            data:[{
              type:'value',
              textAlign:'center',
              axisLine:false,
              min:0,
              tofix:1
            }]
          },
          extra: {
            line: {
              type: "straight",
              width: 2,
              activeType:'hollow'
            }
          }
        }
      };
    },
    onReady() {
      this.getAverageData();
      this.getGlycosylatedData()
    },
    methods: {
      // 时间点平均血糖相关
        getAverageData() {
          //模拟从服务器获取数据时的延时
          setTimeout(() => {
            //模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
            let res = {
              categories: ["00:00", "03:00", "06:00", "09:00", "12:00", "15:00", "18:00", "21:00", "00:00"],
              series: [
                {
                  name: "平均血糖",
                  data: [6, 8, 15, 12, 9, 7, 5, 6, 6]
                }
              ]
            };
            this.chartData = JSON.parse(JSON.stringify(res));
          }, 500);
        },
        // 糖化血红蛋白数值
        getGlycosylatedData(){
          setTimeout(() => {
            //模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
            let res = {
              categories: ["六个月前", "三个月前", "本月"],
              series: [
                {
                  name: "",
                  data: [8, 12, 10]
                }
              ]
            };
            this.chartData1 = JSON.parse(JSON.stringify(res));
          }, 500);
        },
        // 记录血糖
        recordGIS(){
          uni.navigateTo({
            url:'/subpkg/wode/healthPlan/healthPlan'
          })
        }
      }
    
  }
</script>

<style lang="scss">
  page {
    background-color: rgba(235, 236, 237, 1);
    padding-bottom: 30rpx;
  }

  .card {
    width: 672rpx;
    height: 388rpx;
    border-radius: 20rpx;
    margin: 0 auto;
    margin-top: 42rpx;
    background-color: #fff;
    overflow: hidden;

    .timer,
    .timer_num {
      text-align: center;
      font-size: 24rpx;
      font-family: '思源黑体';
    }

    .timer {
      margin-top: 32rpx;
      color: rgba(56, 56, 56, 1);
    }

    .timer_num {
      margin-top: 20rpx;
      color: rgba(166, 166, 166, 1);
    }

    .content {
      display: flex;
      justify-content: space-between;
      width: 412rpx;
      height: 120rpx;
      margin: 0 auto;
      margin-top: 80rpx;

      .left {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        width: 160rpx;
        height: 120rpx;

        .title {
          font-size: 24rpx;
          color: rgba(128, 128, 128, 1);
        }

        .count {
          font-size: 48rpx;
          color: #000;
          font-weight: 400;
        }
      }
    }
  }

  .chatTitle {
    font-size: 36rpx;
    font-weight: 400;
    line-height: 52rpx;
    color: rgba(73, 69, 75, 1);
    margin-top: 20rpx;
    margin-left: 34rpx;
  }
  // 图表
   .charts-box {
      width: 100%;
      height: 300rpx;
    }
    // 更多
    .more{
      position: fixed;
      right: 30rpx;
      bottom: 56rpx;
      width: 112rpx;
      height: 112rpx;
      
      image{
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }
</style>
